package com.bng8.majunzhu.common.exception;

import cn.hutool.http.HttpStatus;

import java.io.Serial;

public class ServiceException extends RuntimeException{

    @Serial
    private static final long serialVersionUID = 187161506868694781L;

    /**
     * 状态码
     *
     * 200:成功
     * 400:未知失败
     * 409:明确的失败
     * 500:系统错误
     */
    private int code = HttpStatus.HTTP_CONFLICT;

    public ServiceException(String message) {
        super(message);
    }

    public ServiceException(int code, String message) {
        super(message);
        this.code = code;
    }

    public ServiceException(Throwable cause) {
        super(cause);
        this.code = 500;
    }

    public int getCode() {
        return this.code;
    }

    public void setCode(int code) {
        this.code = code;
    }
}
